<%@ page language="java" pageEncoding="us-ascii" contentType="text/html;charset=us-ascii" %>
<%--Copyright (C) 2011 Wolfgang Hankeln, Norma J. Wendel

	This file is part of CDinFusion.
	
	CDinFusion is free software: you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public 
	License in version 3 (LGPL3) as published by the Free Software
	Foundation version 3 of the License.
	
	CDinFusion is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	Lesser General Public License for more details.
	
	You should have received a copy of the Lesser General Public
	License along with CDinFusion; see the file COPYING. If not,
	write to the Free Software Foundation, 59 Temple Place - Suite 330,
	Boston, MA 02111-1307, USA or see <http://www.gnu.org/licenses/>.
	
	If you have any questions, send an email to: megx@mpi-bremen.de.
--%>
<%@ page import="org.cdinfusion.data.*"%>
<%@ page import="org.cdinfusion.data.studytype.*"%>
<%@ page import="org.cdinfusion.data.environment.*"%>
<%@ page import="java.util.List"%>
<%System.out.println("<<<<<<<<<<2a_GSC_SELECTED_1to1>>>>>>>>>>");%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<style type="text/css">
</style>
<title> DIRECT CONTEXTUAL DATA INPUT 1 TO 1</title> 
<jsp:include page="googleanalytics.jsp"/>

<script type="text/javascript"> 
function openpopup(url){
	fenster=window.open(url, "_blank", "width=600,height=400,status=yes, scrollbars=yes, resizable=yes, toolbar=1, menubar=1, location=1");
	fenster.focus();
	return false;
}
function select() {
var num = 1;
/*study = none & env = none*/
result = document.Formular.StudyTypeDropDown.value.match("none") && document.Formular.EnvParamDropDown.value.match("none");
if(result){
  	num = -1;
}
/*if !submit == upload*/
if(num == -1){
	alert("Please select a type of report and a environmental package!");
    document.Formular.StudyTypeDropDown.focus();
    return false;
}
/*study = none*/
result = document.Formular.StudyTypeDropDown.value.match("none");
if(result){
  	num = -1;
}
if(num == -1){
	alert("Please select a type of report!");
    document.Formular.StudyTypeDropDown.focus();
    return false;
}
/*env = none*/
result = document.Formular.EnvParamDropDown.value.match("none");
if(result){
  	num = -1;
}
if(num == -1){
	alert("Please select a environmental package!");
    document.Formular.EnvParamDropDown.focus();
    return false;
}
}/*end function*/
</script>
</head>

<body>
<table border="0" width="100%" bgcolor="#2B3990" cellpadding=0 cellspacing=0>
<tr bgcolor="#ffffff">
<td width=250>
<center>
<img height="81" width="250" alt="CDinFusion Logo" src="/CDinFusion/img/logo_small_dark.png">
</center>
</td>
</tr>

<tr align="left">    
<td>
<jsp:include page="documentation/navigation.jsp"></jsp:include>
</td>
</tr>

<%
String sessionID = session.getId();
String origin = (String) session.getAttribute("origin");
String context_exists = "no";
String studytype = "";
String envtype = "";
String seqID = "";

List<String> seqIDs = (List<String>) session.getAttribute("allSequenceIDs");

if(origin.contains("uploadfasta_one")){
	seqID = seqIDs.get(0);
}
if(origin.contains("2a_csv")){
	context_exists = (String) session.getAttribute("context_exists");
	List<CDElement> cdeLIST = (List<CDElement>) session.getAttribute("cdeLIST");
	studytype = cdeLIST.get(0).getStudy().getClass().toString().substring(36).toLowerCase().trim();
	envtype = cdeLIST.get(0).getEnv().getClass().toString().substring(38).toLowerCase().trim();
	seqID = cdeLIST.get(0).getFirstSequenceID();
}
if(origin.contains("5")){
	context_exists = (String) session.getAttribute("context_exists"); //true yes
	List<CDElement> oldLIST = (List<CDElement>) session.getAttribute("cdeLIST");
	studytype = oldLIST.get(0).getStudy().getClass().toString().toLowerCase().substring(36).trim();
	envtype = oldLIST.get(0).getEnv().getClass().toString().toLowerCase().substring(38).trim();
	seqID = oldLIST.get(0).getFirstSequenceID();
	session.setAttribute("oldLIST", oldLIST);
}
session.setAttribute("context_exists", context_exists);
%>

<tr bgcolor="#ffffff">
<td>
<div class="center_div">    
<br>
<center><b> Specify GSC compliant contextual data:</b> <a href="gsc_package_info.htm?item=general" target="_blank" onclick="openpopup(this.href); return false"> more info </a><br /><br>
Chose type of report and environmental package: <br />

</center>
<center>
<p>sequence identifier:  <strong><%=seqID%></strong></p>
</center>

<center>			
  	<form action="upload.htm?_flowId=fileupload&amp;sessionID=<%=sessionID%>" id="fileupload" name="fileupload" method="POST" >
		<%System.out.println("destination: upload.htm");%>
		<input type="hidden" name="sessionID" value="<%=sessionID%>">
		<%session.setAttribute("origin", "2a");%>
		<p> If you filled already the csv file, do you want to upload it now?
		<input class="submitbutton" style="width: 175px" type="submit" name="Submit" value="upload" id="upload" />
		</p>			
	</form>
</center>
<center>
<form name="Formular" action="GSC_choice_a.htm" method="post" onsubmit="return select()">
	<%System.out.println("destination: GSC_choice_a.htm");%>
	<p> 
		type of report:
		<select name="StudyTypeDropDown" size="1"> 
   				<option value="none">none selected</option>
   			<%
   			if(studytype.equals("mimarks_s")){%> 
   				<option selected value="mimarks_s">MIMARKS survey (mimarks_s)</option>
   			<%}
   			else{%>
   				<option value="mimarks_s">MIMARKS survey (mimarks_s)</option>
   			<%}
   			if(studytype.equals("mimarks_c")){%>
   				<option selected value="mimarks_c">MIMARKS culture (mimarks_c)</option>
   			<%}
   			else{%>
   				<option value="mimarks_c">MIMARKS culture (mimarks_c)</option>
   			<%}
   			if(studytype.equals("eu")){%>
   				<option selected value="eu">MIGS eukaryotes (eu)</option>
   			<%}
   			else{%>
   				<option value="eu">MIGS eukaryotes (eu)</option>
   			<%}
   			if(studytype.equals("ba")){%>
   				<option selected value="ba">bacteria and archaea (ba)</option>
   			<%}
   			else{%>
   				<option value="ba">MIGS bacteria and archaea (ba)</option>  
   			<%}
   			if(studytype.equals("pl")){%>
    				<option selected value="pl">MIGS plasmid (pl)</option>
			<%}
 			else{%>
    			<option value="pl">MIGS plasmid (pl)</option>
   			<%}
    		if(studytype.equals("vi")){%>
    			<option selected value="vi">MIGS virus (vi)</option>
   			<%}
   			else{%>
   				<option value="vi">MIGS virus (vi)</option>
    		<%}
   			if(studytype.equals("org")){%>
  				<option selected value="org">MIGS organelle (org)</option>
   			<%}
   			else{%>
    			<option value="org">MIGS organelle (org)</option>
    		<%}
     		if(studytype.equals("me")){%>
     			<option selected value="me">MIMS metagenome (me)</option>
     		<%}
     		else{%>
     			<option value="me">MIMS metagenome (me)</option>
     		<%}%>
     	</select>
    	<a href="gsc_package_info.htm?item=typeofreport" target="_blank" onclick="openpopup(this.href); return false"> more info </a></p>
    	
	<p>
		environmental package:
		<select name="EnvParamDropDown" size="1"> 
   				<option value="none">none selected</option>
    		<%
    		if(envtype.equals("water")){%>
    			<option selected value="water">water</option>
   			<%}
   			else{%>
   				<option value="water">water</option>
   			<%}
   			if(envtype.equals("wastewater")){%>
   				<option selected value="wastewater">wastewater/sludge</option>
   			<%}
   			else{%>
   				<option value="wastewater">wastewater/sludge</option>
   			<%}
   			if(envtype.equals("soil")){%>
   				<option selected value="soil">soil</option>
   			<%}
   			else{%>
   				<option value="soil">soil</option>
   			<%}
   			if(envtype.equals("sediment")){%>
   				<option selected value="sediment">sediment</option>
   			<%}
   			else{%>
   				<option value="sediment">sediment</option>
   			<%}
   			if(envtype.equals("plant_associated")){%>
   				<option selected value="plant_associated">plant-associated</option>
   			<%}
   			else{%>
   				<option value="plant_associated">plant-associated</option>
   			<%}
   			if(envtype.equals("miscellaneous")){%>
   				<option selected value="miscellaneous">miscellaneous</option>
   			<%}
   			else{%>
   				<option value="miscellaneous">miscellaneous</option>
   			<%}
   			if(envtype.equals("biofilm")){%>
   				<option selected value="biofilm">microbial mat/biofilm</option>
   			<%}
   			else{%>
   				<option value="biofilm">microbial mat/biofilm</option>
   			<%}
   			if(envtype.equals("human_vaginal")){%>
   				<option selected value="human_vaginal">human-vaginal</option>
   			<%}
   			else{%>
   				<option value="human_vaginal">human-vaginal</option>
   			<%}
   			if(envtype.equals("human_skin")){%>
   				<option selected value="human_skin">human-skin</option>
   			<%}
   			else{%>
   				<option value="human_skin">human-skin</option>
   			<%}
   			if(envtype.equals("human_oral")){%>
   				<option selected value="human_oral">human-oral</option>
   			<%}
   			else{%>
   				<option value="human_oral">human-oral</option>
   			<%}
   			if(envtype.equals("human_gut")){%>
   				<option selected value="human_gut">human-gut</option>
   			<%}
   			else{%>
   				<option value="human_gut">human-gut</option>
   			<%}
   			if(envtype.equals("human_associated")){%>
   				<option selected value="human_associated">human-associated</option>
   			<%}
   			else{%>
   				<option value="human_associated">human-associated</option>
   			<%}
   			if(envtype.equals("host_associated")){%>
   				<option selected value="host_associated">host-associated</option>
   			<%}
   			else{%>
   				<option value="host_associated">host-associated</option>
   			<%}
   			if(envtype.equals("air")){%>
   				<option selected value="air">air</option>
   			<%}
   			else{%>
   				<option value="air">air</option>
   			<%}%>
    	</select>
    	<a href="gsc_package_info.htm?item=environmentalpackage" target="_blank" onclick="openpopup(this.href); return false"> more info </a></p>
    	<br>
  		<center>
  			<p> current selection as empty spreadsheet template <input class="submitbutton" type="submit" name="submit" value="download empty csv"></p>
			<input class="submitbutton" type="submit" name="submit" value="proceed">
		</center>
</form>
</center>
</div>
</td>
</tr>
<tr bgcolor="#ffffff"><td align="right" height=30>
	<img height="20" width="200" alt="CDinFusion Step 2" src="/CDinFusion/img/step2.png">
</td></tr>
<jsp:include page="documentation/bottom_info.jsp"></jsp:include>
</table>
</body>
</html>